import java.awt.Image;


public abstract class Target {

	protected double 	posX;
	protected double 	posY;

	protected int       lifePoints;
	protected boolean 	isLiving;
	protected boolean   isInvincible;

	protected Image 	image;
	protected int       imageHeight;
	protected int       imageWidth;

	protected abstract void update(Map map);
	protected abstract void receiveDamage(int type);
	protected abstract void setDead();
	protected abstract int  getKillingPoints();
	protected abstract void loadExplosionImg();
	
	private boolean isExploding = false;
	private double	explosionBeginTime = 0;
	protected Image[] imageArrayExplosion = new Image[3];
	private int		imgExplosion = 0;
	private boolean hasExplosed = false;

	protected void setPosition(int i, int j) {
		this.posX = i;
		this.posY = j;
	}
	
	protected void updateExplosion(){
		double time_passed;
		time_passed = (System.currentTimeMillis() - this.explosionBeginTime);
		if(time_passed < 100) 
			this.imgExplosion = 0;
		else if(time_passed < 200) 
			this.imgExplosion = 1;
		else if(time_passed < 300) 
			this.imgExplosion = 2;
		else{
			this.hasExplosed = true;
		}
	}
	
	public void explose(){
		if(!this.isExploding){
			this.explosionBeginTime = System.currentTimeMillis();
			this.isExploding = true;
			this.hasExplosed = false;
		}
	}
	
	public boolean isExploding(){
		return this.isExploding;
	}
	
	public boolean hasExplode() { 
		return this.hasExplosed;
	}	

	public boolean  isAlive(){
		return this.isLiving;
	}

	public Image 	getImage() {
		if(!this.isExploding){
			return this.image;
		}
		else if(!this.hasExplosed){
			return this.imageArrayExplosion[this.imgExplosion];
		}
		else {
			return null;
		}
	}

	public double 	getX() {
		return this.posX;
	}

	public double 	getY() {
		return this.posY;
	}

	public int 		getImageHeight() {
		return imageHeight;
	}

	public int 		getImageWidth() {
		return imageWidth;
	}
}
